using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class tbCTHinhAnhBUS
    {
        public static void Insert(tbCTHinhAnh cthinhanh)
        {
            tbCTHinhAnhDAL cthaDAL = new tbCTHinhAnhDAL();
            cthaDAL.Insert(cthinhanh);
        }
        public static void Update(tbCTHinhAnh cthinhanh)
        {
            tbCTHinhAnhDAL cthaDAl = new tbCTHinhAnhDAL();
            cthaDAl.Update(cthinhanh);
        }
        public static void Delete(int iD)
        {
            tbCTHinhAnhDAL cthaDAl = new tbCTHinhAnhDAL();
            cthaDAl.Delete(iD);
        }
        public static tbCTHinhAnhCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbCTHinhAnhDAL cthaDAL = new tbCTHinhAnhDAL();
            return cthaDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTHinhAnhCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTHinhAnhDAL cthaDAL = new tbCTHinhAnhDAL();
            return cthaDAL.Get(cri.Criter, 0, 0, tbCTHinhAnhColumns.HinhAnh.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbCTHinhAnh GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbCTHinhAnhColumns.HinhAnh.ToString(), Condition.EQUAL, iD);
            tbCTHinhAnhDAL cthaDAL = new tbCTHinhAnhDAL();
            tbCTHinhAnhCollection cthaCollection = cthaDAL.Get(cri.Criter, 0, 0, tbCTHinhAnhColumns.HinhAnh.ToString(), OrderDirection.ASC.ToString(), out total);
            if (cthaCollection.Count > 0)
                return cthaCollection[0];
            return null;
        }
        public static tbCTHinhAnhCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTHinhAnhDAL cthaDAL = new tbCTHinhAnhDAL();
            return cthaDAL.Get(cri.Criter, 1, number, tbCTHinhAnhColumns.HinhAnh.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbCTHinhAnhCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTHinhAnhDAL cthaDAL = new tbCTHinhAnhDAL();
            return cthaDAL.Get(cri.Criter, 1, number, tbCTHinhAnhColumns.HinhAnh.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
